package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;

class zash {
   private HashMap a;
   private Object b;

   zash(Object var1) {
      this.b = var1;
      this.a = new HashMap();
   }

   void a() {
      this.a.clear();
   }

   boolean a(int var1) {
      return this.a.containsKey(var1);
   }

   void a(int var1, int var2) {
      for(int var3 = var1; (var3 & '\uffff') <= (var2 & '\uffff'); ++var3) {
         this.a.remove(var3);
      }

   }

   void b(int var1) {
      this.a.remove(var1);
   }

   void a(zash var1) {
      this.a = com.aspose.cells.b.a.a.zf.b(var1.a);
      this.a.clear();
      Iterator var2 = var1.a.values().iterator();

      while(var2.hasNext()) {
         zbjo var3 = (zbjo)var2.next();
         Object var4 = var3.d();
         switch(var3.c()) {
         case 3:
            Hyperlink var5 = new Hyperlink();
            var5.a((Hyperlink)var4);
            var4 = var5;
            break;
         case 4:
            var4 = (byte[])com.aspose.cells.b.a.za.a((byte[])((byte[])var4));
         }

         zbjo var6 = new zbjo(var3.b(), var3.c(), var4);
         this.a.put(var6.b(), var6);
      }

   }

   int b() {
      return this.a.size();
   }

   ArrayList c() {
      ArrayList var1 = new ArrayList();
      Iterator var2 = this.a.values().iterator();

      while(var2.hasNext()) {
         zbjo var3 = (zbjo)var2.next();
         com.aspose.cells.b.a.a.ze.a(var1, (Object)var3);
      }

      Collections.sort(var1, new zms());
      return var1;
   }

   int d() {
      Hyperlink var1 = null;
      int var2 = this.a.size() * 6;
      Iterator var3 = this.a.values().iterator();

      while(var3.hasNext()) {
         zbjo var4 = (zbjo)var3.next();
         if (var4.a()) {
            switch(var4.c()) {
            case 2:
               String var5 = (String)var4.d();
               var2 += var5.length() * 2 + 2;
               break;
            case 3:
               var1 = (Hyperlink)var4.d();
               zadq var6 = new zadq(var1.getArea(), "", var1.getAddress(), var1);
               int var7 = var6.d() - 8;
               byte[] var8 = new byte[var7];
               System.arraycopy(var6.e(), 8, var8, 0, var7);
               var4.a(var8);
               var4.a(4);
               var2 += var7;
               break;
            case 4:
               var2 += ((byte[])((byte[])var4.d())).length;
               break;
            case 5:
               var2 += ((byte[])((byte[])var4.d())).length;
            }
         }
      }

      if (this.b instanceof zbnw && var1 != null && var1.getScreenTip() != null && !"".equals(var1.getScreenTip())) {
         ((zbnw)this.b).f().a(50061, 2, var1.getScreenTip());
      }

      return var2;
   }

   zbjo c(int var1) {
      return (zbjo)this.a.get(var1);
   }

   static boolean b(int var0, int var1) {
      if (var1 == 0) {
         return false;
      } else {
         switch(var0 & 65535 & 16383) {
         case 325:
         case 326:
         case 337:
         case 341:
         case 342:
         case 343:
            return true;
         case 327:
         case 328:
         case 329:
         case 330:
         case 331:
         case 332:
         case 333:
         case 334:
         case 335:
         case 336:
         case 338:
         case 339:
         case 340:
         default:
            return false;
         }
      }
   }

   void a(int var1, int var2, Object var3) {
      if (var3 == null) {
         this.b(var1);
      } else {
         zbjo var4 = this.c(var1);
         if (var4 != null) {
            var4.a(var2);
            var4.a(var3);
         } else {
            this.a.put(var1, new zbjo(var1, var2, var3));
         }
      }
   }

   Hyperlink e() {
      zbjo var1 = this.c(50050);
      if (var1 == null) {
         return null;
      } else if (var1.c() == 4) {
         byte[] var2 = (byte[])((byte[])var1.d());
         HyperlinkCollection var3 = new HyperlinkCollection((Object)null);
         byte[] var4 = new byte[var2.length + 8];
         System.arraycopy(var2, 0, var4, 8, var2.length);
         var3.a(var4);
         var1.a(3);
         var1.a(var3.get(0));
         if (this.b != null && this.b instanceof zbnw) {
            zbnw var5 = (zbnw)this.b;
            if (var5.d() != null) {
               String var6 = var5.f().e(50061);
               if (var6 != null && !"".equals(var6)) {
                  var3.get(0).setScreenTip(var6);
                  var5.f().b(50061);
               }
            }
         }

         return var3.get(0);
      } else {
         return var1.c() == 3 ? (Hyperlink)var1.d() : null;
      }
   }

   byte[] d(int var1) {
      zbjo var2 = this.c(var1);
      if (var2 == null) {
         return null;
      } else {
         return var2.c() == 4 ? (byte[])((byte[])var2.d()) : null;
      }
   }

   byte[] f() {
      zbjo var1 = this.c(49542);
      if (var1 == null) {
         var1 = this.c(33158);
         if (var1 == null) {
            return null;
         }
      }

      return var1.c() == 4 ? (byte[])((byte[])var1.d()) : null;
   }

   String e(int var1) {
      zbjo var2 = this.c(var1);
      if (var2 == null) {
         return "";
      } else {
         switch(var2.c()) {
         case 2:
            return (String)var2.d();
         case 4:
            byte[] var3 = (byte[])((byte[])var2.d());
            return Encoding.getUnicode().a(var3, 0, var3.length - 2);
         default:
            return null;
         }
      }
   }

   int c(int var1, int var2) {
      zbjo var3 = this.c(var1);
      if (var3 == null) {
         return var2;
      } else {
         Object var4 = var3.d();
         return var4 instanceof Color ? ((Color)var4).toArgb() & 16777215 : (Integer)var3.d();
      }
   }

   boolean a(int var1, int var2, boolean var3) {
      zbjo var4 = this.c(var1);
      if (var4 == null) {
         return var3;
      } else {
         long var5 = (long)(Integer)var4.d();
         int var7 = 1 << var2;
         if (((var5 & 4294967295L) >> 16 & (long)var7) == 0L) {
            return var3;
         } else {
            return (var5 & 4294967295L & (long)var7) != 0L;
         }
      }
   }

   void b(int var1, int var2, boolean var3) {
      long var4 = (long)(1 << var2);
      zbjo var6 = this.c(var1);
      if (var6 == null) {
         var6 = new zbjo(var1, 0, 0);
         this.a.put(var1, var6);
      }

      long var7 = com.aspose.cells.a.c.zi.a(var6.d());
      long var9 = var4 << 16 & 4294967295L;
      var7 &= ~((var9 & 4294967295L) + (var4 & 4294967295L));
      var7 |= var3 ? (var9 & 4294967295L) + (var4 & 4294967295L) : var4 << 16 & 4294967295L;
      var6.a((int)(var7 & 4294967295L));
   }

   float a(int var1, float var2) {
      zbjo var3 = this.c(var1);
      if (var3 == null) {
         return var2;
      } else {
         int var4 = (Integer)var3.d();
         return (float)(var4 >> 16) + (float)(var4 & '\uffff') / 65536.0F;
      }
   }

   void b(int var1, float var2) {
      int var3 = (int)var2;
      int var4 = (var3 << 16) + (int)((var2 - (float)var3) * 65536.0F);
      this.a(var1, 0, var4);
   }

   static int a(float var0) {
      int var1 = (int)var0;
      int var2 = (var1 << 16) + (int)((var0 - (float)var1) * 65536.0F);
      return var2;
   }

   static float f(int var0) {
      return (float)(var0 >> 16) + (float)(var0 & '\uffff') / 65536.0F;
   }

   WorksheetCollection g() {
      if (this.b instanceof zbnw) {
         return ((zbnw)this.b).g().b();
      } else {
         return this.b instanceof FillFormat ? ((FillFormat)this.b).a.getWorksheets() : null;
      }
   }

   Color a(int var1, Color var2) {
      zbjo var3 = this.c(var1);
      if (var3 == null) {
         return var2;
      } else if (var3.c() == 1) {
         return (Color)var3.d();
      } else {
         int var4 = (Integer)var3.d();
         Color var5;
         switch(var4 >> 24 & 255) {
         case 0:
         case 2:
         case 4:
            var5 = Color.fromArgb(var4 & 255, var4 >> 8 & 255, var4 >> 16 & 255);
            var3.a(var5);
            var3.a(1);
            break;
         case 1:
         case 8:
            var5 = this.g().m().e(var4 & 16777215);
            if (com.aspose.cells.a.c.zh.a(var5)) {
               return var2;
            }

            var3.a(var5);
            var3.a(1);
            break;
         case 3:
         case 5:
         case 6:
         case 7:
         case 9:
         case 10:
         case 11:
         case 12:
         case 13:
         case 14:
         case 15:
         default:
            return var2;
         case 16:
            return var2;
         }

         return var5;
      }
   }

   boolean g(int var1) {
      zbjo var2 = this.c(var1);
      if (var2 == null) {
         return true;
      } else if (var2.c() == 1) {
         return com.aspose.cells.a.c.zh.a((Color)var2.d());
      } else {
         int var3 = (Integer)var2.d();
         switch(var3 >> 24 & 255) {
         case 1:
         case 8:
            return (var3 & 16777215) >= 64;
         case 16:
            return true;
         default:
            return false;
         }
      }
   }

   int a(Shape var1, byte[] var2, int var3, boolean var4) {
      byte var5 = 3;
      int var15 = var5 | this.b() << 4;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var15), 0, var2, var3, 2);
      if (var4) {
         var2[var3 + 2] = 34;
         var2[var3 + 3] = -15;
      } else {
         var2[var3 + 2] = 11;
         var2[var3 + 3] = -16;
      }

      int var6 = this.d();
      System.arraycopy(com.aspose.cells.b.a.zc.a(var6), 0, var2, var3 + 4, 4);
      var3 += 8;
      ArrayList var7 = this.c();
      int var8 = var3 + var7.size() * 6;

      for(Iterator var9 = var7.iterator(); var9.hasNext(); var3 += 6) {
         zbjo var10 = (zbjo)var9.next();
         System.arraycopy(com.aspose.cells.b.a.zc.a(var10.b()), 0, var2, var3, 2);
         switch(var10.c()) {
         case 0:
            if ((var10.b() & '\uffff') == 4) {
               double var16 = (double)f((Integer)var10.d());
               if (var1 != null && var1.isFlippedHorizontally() ^ var1.isFlippedVertically()) {
                  var16 = -var16;
                  if (var16 < 0.0D) {
                     var16 += 360.0D;
                  }
               }

               int var17 = a((float)var16);
               System.arraycopy(com.aspose.cells.b.a.zc.a(var17), 0, var2, var3 + 2, 4);
            } else {
               System.arraycopy(com.aspose.cells.b.a.zc.a((Integer)var10.d()), 0, var2, var3 + 2, 4);
            }
            break;
         case 1:
            Color var11 = (Color)var10.d();
            if (com.aspose.cells.a.c.zh.a(var11)) {
               switch(var10.b()) {
               case 448:
                  var2[var3 + 2] = 64;
               default:
                  var2[var3 + 5] = 8;
               }
            } else {
               var2[var3 + 2] = com.aspose.cells.a.c.zh.b(var11);
               var2[var3 + 3] = com.aspose.cells.a.c.zh.c(var11);
               var2[var3 + 4] = com.aspose.cells.a.c.zh.d(var11);
            }
            break;
         case 2:
            byte[] var13 = Encoding.getUnicode().a((String)var10.d());
            System.arraycopy(com.aspose.cells.b.a.zc.a(var13.length + 2), 0, var2, var3 + 2, 4);
            System.arraycopy(var13, 0, var2, var8, var13.length);
            var8 += var13.length + 2;
         case 3:
         default:
            break;
         case 4:
            byte[] var12 = (byte[])((byte[])var10.d());
            System.arraycopy(com.aspose.cells.b.a.zc.a(var12.length), 0, var2, var3 + 2, 4);
            System.arraycopy(var12, 0, var2, var8, var12.length);
            var8 += var12.length;
            break;
         case 5:
            byte[] var14 = (byte[])((byte[])var10.d());
            System.arraycopy(com.aspose.cells.b.a.zc.a(var14.length - 6), 0, var2, var3 + 2, 4);
            System.arraycopy(var14, 0, var2, var8, var14.length);
            var8 += var14.length;
         }
      }

      return var6 + 8;
   }
}
